package com.module.business.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.module.business.dao.CityDao;
import com.module.business.entity.City;
import com.module.business.service.ICityService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author chengluqiang
 * @since 2019-03-01
 */
@Service
@Transactional
public class CityServiceImpl extends ServiceImpl<CityDao, City> implements ICityService {
	

    static Map<String,String> map = new HashMap<String,String>();

    @Override
	@Cacheable(value="defultCache",cacheManager="redisCacheManager", key="#id", unless="#result==null")
    public String getRedis(String id) {
    	System.out.println("++++++++++++++++redis中没有数据++++++++++++");
    	System.out.println("++++++++++++++++从数据库中查看++++++++++++");
        String val = map.get(id);
        System.out.println("val= "+new Date().getTime()+ val);
        return val;
    }

	@Override
	public boolean save(String id, String val) {
		map.put(id, val);
		return true;
	}
}
